package com.nut.lmsc.service.impl;

import com.nut.lmsc.common.Result;
import com.nut.lmsc.entity.OrderGoods;
import com.nut.lmsc.mapper.OrderGoodsMapper;
import com.nut.lmsc.service.OrderGoodsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.Serializable;
import java.util.List;
import java.util.Set;

@Service
@Slf4j
public class OrderGoodsServiceImpl implements OrderGoodsService {

    @Autowired
    private OrderGoodsMapper orderGoodsMapper;

//    @Override
//    public Result<List<OrderGoods>> selectByOrderId(Long orderId) {
//        List<OrderGoods> list = orderGoodsMapper.selectByOrderId(orderId);
//        return Result.ok(list);
//    }

    @Override
    public Result<OrderGoods> getById(Serializable id) {
        OrderGoods orderGoods = orderGoodsMapper.selectById(id);
        return Result.ok(orderGoods);
    }

    @Override
    public Result add(OrderGoods orderGoods) {
        orderGoodsMapper.insert(orderGoods);
        return Result.ok();
    }

    @Override
    public Result updateById(OrderGoods orderGoods) {
        orderGoodsMapper.updateById(orderGoods);
        return Result.ok();
    }

    @Override
    public Result deleteByIds(Set<Integer> ids) {
        for (Integer id : ids) {
            orderGoodsMapper.deleteById(id);
        }
        return Result.ok();
    }
}